{% extends 'base.html' %}
 {% block bar %}
         <div class="col-md-9" style=  "justify-content: flex-end;">
            <h1 class="page-header">订单管理页面</h1>
        <div class="panel panel-primary">
                <!-- Default panel contents -->
        <div class="panel-heading">新增明细<i class="fa fa-thumb-tack pull-right"></i></div>
            <div  class="panel-body">
                 <!-
            </div>
      </div>
 {% endblock %}
{% block main%}
    <form action="" method="post">
        {% csrf_token %}
        <p>
            <input type="hidden" name="customer_id" value={{ customer_id }}>
        </p>
         <p>
            &nbsp空间名称：<input type="text" name="space_name">
        </p>

        <p>&nbsp<label >商品名称：</label>
            <select  id="select" onchange="changefunc()" name="goods_id_id">
                <option value="" selected:disabled style="diaplay:none">请选择商品</option>
                {% for goods_obj in goods_list %}
                <option  value={{ goods_obj.id }}>{{ goods_obj.goods_name }}</option>
                {% endfor %}
        </select>
        <script>
                function changefunc(){
                    {% for goods_obj in  goods_list%}


                        if  ({{ goods_obj.id }} ==document.getElementById("select").value){

                            document.getElementById("goods_type").value = "{{ goods_obj.goods_type }}";
                            document.getElementById("units").value = "{{ goods_obj.unit }}";
                            document.getElementById("goods_prices").value = "{{ goods_obj.goods_price }}";
                        }else if(document.getElementById("select").value==''){
                            document.getElementById("goods_type").value = "";
                            document.getElementById("units").value = "";
                            document.getElementById("goods_prices").value = "";
                        }
                    {% endfor %}
                }
  </script>


        </p>
        <p>
            &nbsp规格型号：<input id='goods_type' type="text" name="goods_type" disabled="disabled">
        </p>
        <p>
            &nbsp单&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp位：<input id='units' type="text" name="unit" disabled="disabled">
        </p>
        <p>
            &nbsp单&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp价：<input id='goods_prices' type="text" name="goods_price" disabled="disabled">
        </p>

         <p>
            &nbsp成交单价：<input type="text" name="deal_unit">
        </p>
           <p>
            &nbsp面&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp积：<input type="text" name="area">
        </p>
          <p>
            &nbsp数&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp量：<input type="text" name="goods_nums">
        </p>
        <p>
            &nbsp备&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp注：<input type="text" name="remarks">
        </p>

        <p>
            &nbsp&nbsp<button type="submit" class="btn">提交</button>
        </p>

    </form>



{% endblock %}
